package com.jr.mapper;


import com.jr.pojo.BookingStation;
import com.jr.pojo.Station;
import com.jr.uitil.PageHelper;
import com.jr.vo.MyBooking;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;

@Repository
public interface StationMapper {
    //根据session查找相关的岗位
    @Select("select * from station where session=#{session}")
    ArrayList<Station> selectStation(String session);


    //存储预约的工位
    int insertBookingStation(BookingStation b);

    //获取bid,并且能够判断当前工位是否已经有人预定了
    BookingStation selectBid(BookingStation b);

    //获取bid查看是否已经有人预定过的记录
    @Select("select bid from stationbooking where stid=#{stid} and choosedate=#{choosedate} and choosetime=#{choosetime}")
    BookingStation selectbooked(BookingStation bookingStation);


    //将预约的工位放到主键表中
    @Insert("insert into mybooking(userid,timestamps,status) values(#{userid},#{timestamps},#{status})")
    int insertInid(MyBooking mb);

    //查看个人预定的工位
    ArrayList<MyBooking> selectMyBooking(@Param("mb") MyBooking mb, @Param("pageindex") Integer pageindex,@Param("shownum") Integer shownum);

    //查找重复的
    BookingStation selectDuplicateBooking(BookingStation b);

    //修改状态，修改为已取消
    int updateMyBookingStatus(BookingStation b);


    //当已经有预定过的记录时，直接进行更新即可
    int updatebooked(BookingStation bookingStation);

    //更新已经添加的记录
    int updatemybooked( MyBooking myBooking);



}
